package com.ys.web.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ys.web.dao.CommonDao;
import com.ys.web.entity.Role;
import com.ys.web.entity.UserRole;
import com.ys.web.service.RoleService;

@Service
public class RoleServiceImpl implements RoleService {

	@Autowired
	private CommonDao commonDao;
	@Override
	public Integer addRole(Role role) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void updateRole(Role role) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<Role> getRoles() {
		// TODO Auto-generated method stub
		List<Role> roles = commonDao.findByQueryString("from Role");
		return roles;
	}

	@Override
	public void delete(Integer id) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<UserRole> getRoleByUserId(Integer userId) throws Exception {
		List<UserRole> roles = commonDao.findByProperty(UserRole.class, "userId", userId);
		return roles;
	}

}
